<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>浩鲸知识库</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="<%=basePath%>modules/micro/imgs/logo.ico">
    <link href="<%=basePath%>frm/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="<%=basePath%>modules/micro/html/scrollcss.css" rel="stylesheet">

    <script type="text/javascript" charset="utf-8" src="<%=basePath%>frm/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="<%=basePath%>frm/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="<%=basePath%>frm/ueditor/lang/zh-cn/zh-cn.js"></script>
  </head>
  <body onload="qrySubjectDataById()">
    <div style="position: absolute;width:100%">
      <div id="myPageDiv">
        <div style="margin:auto;width:100%;height:100%;margin-top:2px;">
          <div id="subjectDetailDiv" style="font-family: bold;position:relative; height:100%; overflow:auto;text-align: left;">
            <div>
              <script id="editor" type="text/plain" style="width:100%;position:relative; 575px; overflow:hidden;"></script>
            </div>
          </div>
        </div>
      </div>
      <div id="myIframe" style=" width:100%;font-family: bold;overflow: visible;font-size: 16px;text-align: left;">
        <ul class="nav nav-tabs nav-pills">
          <li ><a href="#" onclick="window.history.back(-1)">返回</a></li>
        </ul>
        <iframe id="iframepage" name="iframepage" frameBorder=0 overflow:scroll width="100%"></iframe>
      </div>
    </div>
    <script src="<%=basePath%>frm/bootstrap-3.3.7/js/jquery.min.js"></script>
    <script src="<%=basePath%>frm/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="<%=basePath%>frm/layer/layer.js"></script>
    <%
      String subjectId = (String)request.getParameter("subjectId");//直接传递
      String url = (String)request.getParameter("url");//直接传递
    %>

    <script type="application/javascript">
      var curScreemHeight = $(document).height() - 150;
      //$("#subjectDetailDiv").height(curScreemHeight);

      //加载层-默认风格
      layer.load();
      /**
       * 查询初始化主题数据
       */
      function qrySubjectDataById() {
        var ue = UE.getEditor('editor',{
          toolbars: [],
         // autoHeightEnabled: true,
          autoFloatEnabled: true
          ,enableAutoSave: true,
          topOffset:0
        });


        if('null' != '<%=subjectId%>') {
          $("#titleDiv").show();
          $("#myPageDiv").show();
          $("#myIframe").hide();
          $.post("<%=basePath%>subject/qrySubjectById.do", {subjectId:"<%=subjectId%>"}, function result(data) {
            var subjectData = JSON.parse(data);
            $("#subjectTitle").html(subjectData.subjectTitle);
            ue.ready(function() {
                subjectData.subjectContent = subjectData.subjectContent == null?'无内容' : subjectData.subjectContent;
                //异步回调
                ue.setContent("<span style='color: rgb(255, 0, 0);font-size:14px'><strong>更新时间：" + subjectData.modifyDate+"</strong></span> <br/>"+subjectData.subjectContent);
                //ue.setHeight(350);
                ue.setDisabled();
                $(ue.window).scrollTop(ue.window.scrollMaxY);
              layer.closeAll('loading');
            });

          });
        } else {
          $("#myIframe").show();
          $("#titleDiv").hide();
          $("#myPageDiv").hide();

          iFrameHeight()
        }
      }

      function iFrameHeight() {
        var ifm= document.getElementById("iframepage");
        ifm.src = "<%=url%>";
        ifm.height = $(document).height() - 50;
        $("#editor").height($(document).height()-150);
      }

      /**
       * 匿名回复当前条目
       */
      function replyFunc() {
        if('null' != '<%=subjectId%>') {
          window.location.href="anonymouReplySubject.jsp?subjectId=<%=subjectId%>";
        }
      }
    </script>
  </body>
